trigger setmanagerforMCP on MonthlyCallPlan__c (before insert) {
    list<id> idl=new list<id>();
    list<MonthlyCallPlan__c> mcpl=new list<MonthlyCallPlan__c>();
    list<user> u=new list<user>();
    list<id> uid=new list<id>();
    boolean b=false;
     for(MonthlyCallPlan__c h:trigger.new){
         idl.add(h.id);
         uid.add(h.ownerid);
     }
    
 /*   for(MonthlyCallPlan__c hos:trigger.new){
    if(system.trigger.isupdate){
        if(system.trigger.oldmap.get(hos.id).ownerid != hos.ownerid){
            b=true;
        }
      }if(system.trigger.isinsert){
          b=true;
      }
    }  */
     
//    if(b){
    u=[select id,managerid from user where id in:uid];
 //   }
    
  /*  if(system.trigger.isupdate){
    for(MonthlyCallPlan__c ht:trigger.new){
        if(system.trigger.oldmap.get(ht.id).ownerid != ht.ownerid){
                for(user ul:u){
                    if(ul.id==ht.ownerid){
                        ht.manager__c=ul.managerid;
                }
              }  
            }
        }
    }else */
    if(system.trigger.isinsert){
        for(MonthlyCallPlan__c ht:trigger.new){
                for(user ul:u){
                    if(ul.id==ht.ownerid){
                       ht.manager__c=ul.managerid;
                }
              }  
            }
        }

}